package m202311.d06;

/**
 * @author haocongshun
 * @date 2023/11/06 19:17:01
 */

/**
 * 55. 跳跃游戏
 */
public class Q55 {

    public static void main(String[] args) {
        boolean b = new Q55().canJump(new int[]{1,1,0});
        System.out.println(b);
    }
    public boolean canJump(int[] nums) {
        return canJump(nums, nums.length - 1);
    }

    public boolean canJump(int[] nums, int index) {
        if (index == 0 || nums[0] >= index) {
            return true;
        }
        for (int i = index - 1; i >= 0; i--) {
            if (nums[i] >= (index - i)) {
                return canJump(nums, i);
            }
        }
        return false;
    }
}
